#ifndef MACROS_H
#define MACROS_H

// 辅助宏，用于将宏展开的结果转换为字符串
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

// 定义宏，用于生成标识符
#define DECLARE_CREATE(x) create##x
#define DECLARE_DELETE(x) delete##x

// 使用宏生成标识符并将其转换为字符串
#define DECLARE_CREATE_FUNC(x) x* DECLARE_CREATE(x)()
#define DECLARE_DELETE_FUNC(x) void DECLARE_DELETE(x)(x* ptr)

// Helper macros for interface
#define DECLARE_INTERFACE(x)        \
    typedef x* (*C##x##Func)();     \
    typedef void (*D##x##Func)(x*); \
    DECLARE_CREATE_FUNC(x);         \
    DECLARE_DELETE_FUNC(x);         \

// Helper macros for dlsym
#define DLSYM_CREATE(x) \
    (C##x##Func)dlsym(handle, TOSTRING(DECLARE_CREATE(x)));
#define DLSYM_DELETE(x) \
    (D##x##Func)dlsym(handle, TOSTRING(DECLARE_DELETE(x)));

#endif // MACROS_H
